/**
 * generate by AAMVVM: https://github.com/HeadingMobile/AAMVVM
 */
package com.dodo.videoEdit.ui.mainactivity;

import androidx.fragment.app.Fragment;
import androidx.viewpager2.widget.ViewPager2;

import com.azhon.basic.base.BaseNoModelActivity;
import com.dodo.videoEdit.R;
import com.dodo.videoEdit.databinding.ActivityMainBinding;
import com.dodo.videoEdit.ui.fragment.PeasantMineFragment;
import com.dodo.videoEdit.ui.fragment.adapters.FragmentPagerAdapter;
import com.gauravk.bubblenavigation.BubbleNavigationLinearView;

import java.util.ArrayList;

/**
 * description: MainActivity2
 *
 * @date 2020/08/12
 */

public class MainActivity extends BaseNoModelActivity<ActivityMainBinding> {


    private ArrayList<Fragment> fragList;

    @Override
    protected int onCreate() {
        return R.layout.activity_main;
    }

    @Override
    protected void initView() {
        fragList = new ArrayList<>();
        fragList.add(PeasantMineFragment.newInstance(getString(R.string.home), R.color.red_inactive));
        fragList.add(PeasantMineFragment.newInstance(getString(R.string.search), R.color.blue_inactive));
        fragList.add(PeasantMineFragment.newInstance(getString(R.string.likes), R.color.blue_grey_inactive));
        fragList.add(PeasantMineFragment.newInstance(getString(R.string.notification), R.color.green_inactive));
        fragList.add(PeasantMineFragment.newInstance(getString(R.string.profile), R.color.purple_inactive));
        ViewPager2 viewPager = dataBinding.viewPager;
        BubbleNavigationLinearView bottomNavigationViewLinear = dataBinding.bottomNavigationViewLinear;
        //FragmentAdapter pageAdapter = new FragmentAdapter(getSupportFragmentManager(), fragList);
        FragmentPagerAdapter pageAdapter = new FragmentPagerAdapter(this,fragList);
        viewPager.setAdapter(pageAdapter);
        viewPager.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() {
            @Override
            public void onPageSelected(int position) {
                super.onPageSelected(position);
                 bottomNavigationViewLinear.setCurrentActiveItem(position);
            }
        });
        bottomNavigationViewLinear.setNavigationChangeListener((view, position) -> viewPager.setCurrentItem(position, true));
    }

    @Override
    protected void initData() {

    }

}

